home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.4d7 source / tn3270 / attnmenu.c < prev    next >
Text File  |  1992-04-17  |  6KB  |  208 lines

  1. /*
  2.  *  tn3270 for the Macintosh Source Code
  3.  *  Brown University Computing and Information Services
  4.  *  Version 2.4d7  April, 1992
  5.  *  Copyright (c) 1988, 1989, 1990, 1991, 1992 by Brown University and by
  6.  *  Peter John DiCamillo.
  7.  *
  8.  *  Permission is granted to any individual or institution to use, copy,
  9.  *  or redistribute the binary version of this software and its
  10.  *  documentation provided this notice and the copyright notices are
  11.  *  retained.  Permission is granted to any individual or non-profit
  12.  *  institution to use, copy, modify, or redistribute the source files
  13.  *  of this software provided this notice and the copyright notices are
  14.  *  retained.  This software may not be distributed for profit, either
  15.  *  in original form or in derivative works, nor can the source be
  16.  *  distributed to other than an individual or a non-profit institution.
  17.  *  Any  individual or group interested in seeing and/or using these
  18.  *  source files but who are prevented from doing so by the above
  19.  *  constraints should contact Don Wolfe, Assistant Vice-President for
  20.  *  Computer Systems at Brown University, (401) 863-7250, for possible
  21.  *  software licensing of the source developed at Brown.
  22.  *
  23.  *  Brown University and Peter John DiCamillo make no representations
  24.  *  about the suitability of this software for any purpose.
  25.  *
  26.  *  BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
  27.  *  EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
  28.  *  INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
  29.  *  WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
  30.  *
  31.  */
  32.  
  33. #if !defined(USEDUMP)
  34.     #include "maclib.h"
  35.     #include "termdef.h"
  36.     #include "tn3270funcs.h"
  37.     #include "globals.h"
  38. #else
  39.     #pragma load "tn3270DumpFile"
  40. #endif
  41.  
  42. #pragma segment 3270seg2
  43.  
  44. extern short attnmousepf;
  45.  
  46. extern cnr *cdlgcp;
  47. extern PaletteHandle dlgpalette;
  48. extern RGBColor realblack;
  49.  
  50. pascal void attnmenu(short msg, MenuHandle mhdl, Rect *mr,
  51.                      Point hit, short *which)
  52. {
  53.     Handle mmap;
  54.     BitMap menumap;
  55.     GrafPtr currport;
  56.     static unsigned char coord[3] = {3, 218, 131};
  57.     static unsigned char count[3] = {3, 3, 2};
  58.     Rect keyrect, whichrect, hitrect;
  59.     register short i, j, k, keynum, hitnum;
  60.  
  61.     switch(msg) {
  62.     case mDrawMsg:
  63.         /* define bitmap for menu */
  64.         mmap = GetResource('MMAP', 256);
  65.         menumap.baseAddr = *mmap;
  66.         menumap.rowBytes = 44;
  67.         menumap.bounds.top = 0;
  68.         menumap.bounds.left = 0;
  69.         menumap.bounds.bottom = 101;
  70.         menumap.bounds.right = 343;
  71.         /* get current bitmap */
  72.         GetPort(&currport);
  73.         /* copy bitmap */
  74.         CopyBits(&menumap, &(currport->portBits),
  75.                 &(menumap.bounds), mr, srcCopy, 0L); 
  76.         if (mhdl == 0) break;    /* for dialog call */
  77.         /* change to gray if menu not enabled */
  78.         if (((*mhdl)->enableFlags && 1) == 0) {
  79.             PenMode(notPatBic);
  80.             PenPat(&qd.gray);
  81.             PaintRect(mr);
  82.             PenNormal();
  83.             }
  84.         break;
  85.     case mChooseMsg:
  86.         /* enable next line to capture fkey menu in screen dump */
  87.         /* if (cs.dblevel) GetNextEvent(keyDownMask, &dbevent); */
  88.         /* check for disabled menu */
  89.         if (mhdl != 0)        /* for dialog call */
  90.             if (((*mhdl)->enableFlags && 1) == 0) {
  91.                 if (*which != 0)
  92.                     InvertRect(mr);
  93.                 *which = 0;
  94.                 break;
  95.                 }
  96.         /* loop through all key rectangles. For each,
  97.            check if it is (*which) and if the mouse is
  98.            in it */
  99.         hitnum = 0;
  100.         whichrect.top = 0;
  101.         keynum = 1;
  102.         for (k=0; k < 3; k++) {
  103.             keyrect.top = (*mr).top + 3;
  104.             keyrect.bottom = keyrect.top + 23;
  105.             for (i=0; i < 4; i++) {
  106.                 keyrect.left = (*mr).left + coord[k];
  107.                 keyrect.right = keyrect.left + 40;
  108.                 for (j=0; j < count[k]; j++) {
  109.                     if (keynum == (*which)) {
  110.                         whichrect.top = keyrect.top + 1;
  111.                         whichrect.left = keyrect.left + 1;
  112.                         whichrect.bottom = keyrect.bottom - 1;
  113.                         whichrect.right = keyrect.right - 1;
  114.                         }
  115.                     if (PtInRect(hit, &keyrect)) {
  116.                         hitnum = keynum;
  117.                         hitrect.top = keyrect.top + 1;
  118.                         hitrect.left = keyrect.left + 1;
  119.                         hitrect.bottom = keyrect.bottom - 1;
  120.                         hitrect.right = keyrect.right - 1;
  121.                         }
  122.                     keynum++;
  123.                     keyrect.left += 41;
  124.                     keyrect.right += 41;
  125.                     }
  126.                 keyrect.top += 24;
  127.                 keyrect.bottom += 24;
  128.                 }
  129.             }
  130.         if (hitnum == 0) {
  131.             if (whichrect.top !=0) InvertRect(&whichrect);
  132.             (*which) = hitnum;
  133.             break;
  134.             }
  135.         if ((*which) == hitnum) break;
  136.         (*which) = hitnum;
  137.         if (whichrect.top != 0) InvertRect(&whichrect);
  138.         if (hitnum != 0) InvertRect(&hitrect);
  139.         break;
  140.     case mSizeMsg:
  141.         (*mhdl)->menuWidth = 343;
  142.         (*mhdl)->menuHeight = 101;
  143.         break;
  144.     }
  145. }
  146.  
  147. pascal void attndlg(WindowPtr dlgwindow, short item)
  148. {
  149. GrafPtr gp;
  150. Rect myrect;
  151. short dtype;
  152. Handle ditem;
  153. Point hit;
  154. short which;
  155.  
  156. GetDItem(dlgwindow, item, &dtype, &ditem, &myrect);
  157. GetPort(&gp);
  158. SetPort(dlgwindow);
  159. hit.v = hit.h = 0;
  160. attnmenu(mDrawMsg, (MenuHandle)0L, &myrect, hit, (short *)0L);
  161. which = attnmousepf;
  162. attnmenu(mChooseMsg, (MenuHandle)0L, &myrect, hit, &which);
  163. SetPort(gp);
  164. }
  165.  
  166. pascal void colorbox(WindowPtr wp, short inum)
  167. {
  168. #pragma unused (wp)
  169. Rect irect;
  170. short cnum, newcolor;
  171. RGBColor rgbtemp;
  172. cnum = (inum-5)/2;        /* 0-9 for white through black, background, status */
  173. irect.top = 5 + (cnum*30);
  174. irect.left = 5;
  175. irect.bottom = irect.top+20;
  176. irect.right = irect.left+95;
  177. FrameRect(&irect);
  178. switch(cnum) {
  179.     case 0:    newcolor = RGBwhite;
  180.             break;
  181.     case 1:    newcolor = RGByellow;
  182.             break;
  183.     case 2: newcolor = RGBturquoise;
  184.             break;
  185.     case 3:    newcolor = RGBgreen;
  186.             break;
  187.     case 4:    newcolor = RGBpink;
  188.             break;
  189.     case 5:    newcolor = RGBred;
  190.             break;
  191.     case 6:    newcolor = RGBblue;
  192.             break;
  193.     case 7:    newcolor = RGBblack;
  194.             break;
  195.     case 8:    newcolor = RGBback;
  196.             break;
  197.     case 9:    newcolor = RGBstat;
  198.             break;
  199.     default: break;
  200.     }
  201. GetEntryColor(dlgpalette, newcolor, &rgbtemp);
  202. actualcolor(&rgbtemp, &rgbtemp, cdlgcp);
  203. RGBForeColor(&rgbtemp);
  204. InsetRect(&irect, 1, 1);
  205. PaintRect(&irect);
  206. RGBForeColor(&realblack);
  207. }
  208.